#include <iostream>
#include <vector>
using namespace std;

int maxSatisfied(vector<int> &customers, vector<int> &grumpy, int minutes)
{
    int n = customers.size();
    int goodtime = 0;
    int saveTime = 0;

    for (int i = 0; i < n; i++)
    {
        if (grumpy[i] == 0)
            goodtime += customers[i];
    }

    for (int i = 0; i < minutes; i++)
    {
        if (grumpy[i] == 1)
            saveTime += grumpy[i];
    }

    int maxSaveTime = saveTime;

    for (int i = minutes; i < n; i++)
    {
        if (grumpy[i] == 1)
        {
            saveTime += customers[i];
            cout << "1 :" <<saveTime <<" ";
        }
            
        if (grumpy[i - minutes + 1] == 1)
        {
            saveTime -= customers[i - minutes + 1];
            cout << "2 :" << saveTime << " ";
        }
            
        maxSaveTime = max(maxSaveTime, saveTime);
    }
    cout << endl;
    cout << maxSaveTime << goodtime<<endl;
    return maxSaveTime + goodtime;
}

int main()
{
    vector<int> customers = {1,0,1,2,1,1,7,5};
    vector<int> grumpy = {0,1,0,1,0,1,0,1};
    int m = maxSatisfied(customers,grumpy,3);
    cout << "m : " << m <<endl;
    return 0;
}